package com.xinhe.web.reposity;

import com.xinhe.web.entity.Menu;
import com.xinhe.web.entity.ServiceCenter;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;
import java.util.Map;


public interface AuthMenuRepository extends JpaRepository<Menu, Long> {

    @Query("from Menu where fParentId = -1 and id in ?1")
    List<Menu> findAuthMenuList(List<Long> idList);

    @Query("from Menu where fParentId = ?1")
    List<Menu> findAuthMenuListByParentId(Long fParentId);
    @Query(value = "select DISTINCT m.*  from auth_menu m, auth_role_menu rm  where m.removed = 0 and rm.removed = 0 and m.id = rm.f_menu_id and rm.f_role_id in ?1",nativeQuery = true)
    List<Menu> findByRoleIdIn(Long[] roleIds);
    @Query(value = "select m.*  from auth_menu m  where m.removed = 0 and m.terminal = ?1",nativeQuery = true)
    List<Menu> findByTerminal(Integer terminal);

}